<template>
  <view class="test-page">
    <view class="header">
      <text class="title">测试下载目录管理</text>
    </view>
    
    <view class="content">
      <button @click="testNavigation">测试跳转到目录管理</button>
      <button @click="testDirectoryList">测试目录列表</button>
    </view>
    
    <view class="result" v-if="testResult">
      <text>{{ testResult }}</text>
    </view>
  </view>
</template>

<script>
export default {
  data() {
    return {
      testResult: ''
    }
  },
  methods: {
    testNavigation() {
      console.log('测试导航到目录管理页面')
      this.testResult = '尝试跳转到目录管理页面...'
      
      uni.navigateTo({
        url: '/pages/work/mytool/downloads/directories/index',
        success: () => {
          console.log('跳转成功')
          this.testResult = '跳转成功！'
        },
        fail: (err) => {
          console.log('跳转失败:', err)
          this.testResult = '跳转失败: ' + JSON.stringify(err)
        }
      })
    },
    
    testDirectoryList() {
      try {
        const directories = uni.getStorageSync('customDownloadDirectories') || []
        this.testResult = `自定义目录数量: ${directories.length}`
        console.log('目录列表:', directories)
      } catch (error) {
        this.testResult = '获取目录失败: ' + error.message
      }
    }
  }
}
</script>

<style>
.test-page {
  padding: 30rpx;
}

.header {
  text-align: center;
  margin-bottom: 50rpx;
}

.title {
  font-size: 36rpx;
  font-weight: bold;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 30rpx;
}

button {
  padding: 20rpx;
  background: #007aff;
  color: white;
  border: none;
  border-radius: 10rpx;
}

.result {
  margin-top: 30rpx;
  padding: 20rpx;
  background: #f0f0f0;
  border-radius: 10rpx;
}
</style>